import { DECREMENT, INCREMENT } from "../const/count.const"

const initialState = {
  count: 0
}

const reducer = (state = initialState, action) => {
  // 声明处理函数
  switch (action.type) {
    case INCREMENT:
      return {
        ...state,
        count: state.count + action.payload
      }
    case DECREMENT:
      return {
        ...state,
        count: state.count - action.payload
      }
    default:
      return state
  }
}
export default reducer